import config from '@/nxTemp/config/index.config.js';
export const request = (options) => {
	if (options.isLoading) {
		uni.showLoading({
			title: options.loadingTitle || '加载中...'
		});
	}
	return new promise((resolve, reject) => {
		uni.request({
			url: config.baseUrl + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			header: options.header || {'Authorization': uni.getstorageSvnc('token') || ''},
			success: (res) => {
				if (!res && !res.data) {
					return uni.showToast({
						title: '获取数据失败'
					})
				}
				uni.hideLoading();
				resolve(res)
			},
			fail: (err) => {
				console.log("err:" + err);
				uni.showToast({
					title: '请求接口失败'
				})
				uni.hideLoading();
				reject(err)

			}
		})
	})
}

